<?
ob_start();
session_start();
include("../header.php");
include("../lib/config.php");
$show	= $HTTP_GET_VARS['show'];

// cek hak akses untuk cabang
		$sad = mssql_query("SELECT nama_menu FROM VPrivUser A, VCabang B WHERE username='".$HTTP_SESSION_VARS['user_login']."' AND baca='1' AND A.nama_menu=B.Kode_Cabang",$conn);
		while($rad = mssql_fetch_array($sad)){
		// VARIABLE UNTUK CABANG
		$VAreaCode[] = $rad[0];
		}

?>
<link rel="stylesheet" type="text/css" href="../style/style.css">
<script type="text/javascript">
 function ValSubmit(){
	if(document.forms[0].awal.value == ""){
		alert("Field: Periode Awal tidak boleh kosong ...");
		document.forms[0].awal.focus();
		return false;
	}
	
	if(document.forms[0].akhir.value == ""){
		alert("Field: Periode Akhir tidak boleh kosong ...");
		document.forms[0].akhir.focus();
		return false;
	}
	
	document.forms[0].submit();	
 }
 
 function ValExpExcel(){
	if(document.forms[0].awal.value == ""){
		alert("Field: Periode Awal tidak boleh kosong ...");
		document.forms[0].awal.focus();
		return false;
	}
	
	if(document.forms[0].akhir.value == ""){
		alert("Field: Periode Akhir tidak boleh kosong ...");
		document.forms[0].akhir.focus();
		return false;
	}
	
	var AWAL 	= document.forms[0].awal.value;
	var AKHIR 	= document.forms[0].akhir.value;
	var DIVISI	= document.forms[0].division.value;
	<?
	if($show == "bank"){
	?>
	top.location.href="../report/rep_med_bank.php?excel=yes&awal="+AWAL+"&akhir="+AKHIR+"&division="+DIVISI+"";
	<?
	}
	elseif($show == "restitusi"){
	?>
	top.location.href="../report/rep_med_restitusi.php?excel=yes&awal="+AWAL+"&akhir="+AKHIR+"&division="+DIVISI+"";
	<?
	}
	elseif($show == "detail"){
	?>
	var KEYWORD = document.forms[0].keyword.value;
	top.location.href="../report/rep_med_detail.php?excel=yes&awal="+AWAL+"&akhir="+AKHIR+"&division="+DIVISI+"&keyword="+KEYWORD+"";
	<?
	}
	?>
 }
 
</script>
<?

if($show == "bank"){
	$action = "../report/rep_med_bank.php";
	$title	= "DAFTAR TRANSFER UANG KESEHATAN";
}
elseif($show == "restitusi"){
	$action = "../report/rep_med_restitusi.php";
	$title	= "DATA KLAIM BIAYA PENGOBATAN, KACAMATA, RAWAT INAP (RUMAH SAKIT), DAN PERSALINAN";
}
elseif($show == "detail"){
	$action = "../report/rep_med_detail.php";
	$title	= "DATA DETAIL KLAIM BIAYA PENGOBATAN, KACAMATA, RAWAT INAP (RUMAH SAKIT), DAN PERSALINAN";
}
?>
<br />
<fieldset><legend><b>Laporan Pengobatan Karyawan - <?=$title?></b></legend>
<table width="100%" height="300"> 
 <form action="<?=$action?>" method="get" target="_blank">
 <tr>
  <td valign="top">
	<table border="0">
	 <tr>
	  <td>Periode</td>
	  <td><input type="text" maxlength="10" size="11" name="awal" /> <a href="javascript:calA.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a>&nbsp;s/d&nbsp;<input type="text" maxlength="10" size="11" name="akhir" /> <a href="javascript:calB.popup();"><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Kalendar" title="Kalendar"></a></td>
	 </tr>
	 <tr>
	  <td>Divisi</td>
	  <td colspan="10"><select name="division">
<!--          <option value="">--semua divisi--</option>-->
		   <?
            $sqlQ   = "SELECT * FROM VLevelCabang WHERE status='1' ";
            $sqlQ	.= "AND AreaCode IN (";
        
            for($k=0;$k<count($VAreaCode);$k++){
                $sqlQ .= "'$VAreaCode[$k]',";
            }
        
            $sqlQ 	.= "'$VAreaCode[0]') ";		
            $sqlQ 	.= " ORDER BY uraian ASC";
        
            $sql2 = mssql_query($sqlQ,$conn);
                echo"<option value='ALL'>--SEMUA--</option>";
            while($row2 = mssql_fetch_array($sql2)){
                echo"
                 <option value='$row2[kode_so]'>$row2[uraian]</option>
                ";
            }
           ?>
          </select></td>
	 </tr>
     <?
     if($show == "detail"){
	 ?>
     <tr>
      <td>Nama/NIK</td>
      <td colspan="10"><input type="text" name="keyword" /></td>
     </tr>
	 <?
     }
	 ?>
	 <tr>
	  <td>&nbsp;</td>
	  <td><input type="button" class="button" onclick="Javascript:ValSubmit();" value="Preview" /><input type="button" class="button" value="Export Excel" onclick="Javascript:ValExpExcel();" /></td>
	 </tr>
	</table>
<script language="javascript">
	var calA = new calendar1(document.forms[0].elements['awal']);
	calA.year_scroll = true;
	calA.time_comp = false;

	var calB = new calendar1(document.forms[0].elements['akhir']);
	calB.year_scroll = true;
	calB.time_comp = false;
</script>
  </td>
  </form> 
 </tr>
</table>
<?
echo"</div>
	  </td>
	   </tr>
	    </table>
";
include("../menu.php");
?>